import { createSlice } from "@reduxjs/toolkit";

const counter=createSlice({
    name:"counter",
    initialState:{
        frontImg:'',
        backImg:'',
        userId:'',
        userName:'',
        mobile:'',
        password:'',
        standingName:'',
        standingId:'',
        standingList:[],
        sidebarList:[],
        authentication:'',
        city:'',
        coordinate:'',
    },
    reducers:{
        addFrontImg(state,{payload}){
            state.frontImg=payload
        },
        addBackImg(state,{payload}){
            state.backImg=payload
        },
        setUser(state,{payload}){
            state.userId=payload._id
            state.userName=payload.username
            state.mobile=payload.mobile
            state.password=payload.password
            state.standingName=payload.standing.name
            state.standingId=payload.standing._id
        },
        setStandingList(state,{payload}){
            state.standingList=payload
        },
        setsidebarList(state,{payload}){
            state.sidebarList=payload
        },
        editPassword(state,{payload}){
            state.password=payload
        },
        addauthentication(state,{payload}){
            state.authentication=payload
        },
        delauthentication(state){
            state.authentication=''
        },
        editmobile(state,{payload}){
            state.mobile=payload
        },
        setcity(state,{payload}){
            state.city=payload
        },
        coordinate(state,{payload}){
            state.coordinate=payload
        }
    }
})

export let {coordinate,setcity,editmobile,addFrontImg,addBackImg,setUser,setStandingList,setsidebarList,editPassword,addauthentication,delauthentication}=counter.actions
export default counter.reducer